<script lang="ts" setup>
import { reactive, ref, defineEmits } from 'vue'
import { refs, createRef, aesDecrypt  } from 'dsrz/utils'
// import { aesEncrypt, aesDecrypt } from 'dsrz/utils/aes'
defineOptions({
  name: 'toLeadOrUpdate',
})

// 定义 props
const props = defineProps<{
  visible: boolean,
}>()

const emit = defineEmits(['close'])

const details = reactive({
  title: '查看班级',
  params: {
    teacherHistory: [],
  } as any,
})

const editor = (value: any) => {
  Object.assign(details.params, value)
}

const cancel = () => {
  Object.assign(details,{ 
        params: { teacherHistory: [] }
    })
  emit('close') // 通知父组件关闭弹出框
}

defineExpose({
  editor,
})
</script>
<template>
  <CurrencyDialog
    v-model="props.visible"
    :title="details.title"
    width="1000"
    style="padding-bottom: 10px"
    @cancel="cancel"
    @confirm="cancel"
  >
    <div class="lastBox">
      <div>
        <div class="box">班级名称</div>
        <span>{{ details.params.name }}</span>
      </div>
      <div>
        <div class="box">所属年级</div>
        <span>{{ details.params.gradeName }}</span>
      </div>
      <div>
        <div class="box">所属专业</div>
        <span>{{ details.params.majorName }}</span>
      </div>
    </div>
    <div class="lastBox">
      <div v-if="details.params?.code">
        <div class="box">班号</div>
        <span>{{ details.params?.code }}</span>
      </div>
      <div v-if="details.params?.campusName">
        <div class="box">校区</div>
        <span>{{ details.params?.campusName }}</span>
      </div>
      <div v-if="details.params?.typeName">
        <div class="box">班级类别</div>
        <span>{{ details.params?.typeName }}</span>
      </div>
    </div>
    <div class="lastBox">
      <div>
        <div class="box">班主任</div>
        <span v-if="details.params.headmasterName">{{
          aesDecrypt(details.params.headmasterName)
        }}</span>
      </div>
      <div>
        <div class="box">辅导员</div>
        <span v-if="details.params.instructorName">{{
          aesDecrypt(details.params.instructorName)
        }}</span>
      </div>
      <div>
        <div class="box">创建时间</div>
        <span>{{ details.params.createTime }}</span>
      </div>
    </div>
    <div class="lastBox">
      <div>
        <div class="box">班级人数</div>
        <span>{{ details.params.studentNum }}</span>
      </div>
      <div>
        <div class="box">男生人数</div>
        <span>{{ details.params.boyNum }}</span>
      </div>
      <div>
        <div class="box">女生人数</div>
        <span>{{ details.params.girlNum }}</span>
      </div>
    </div>
    <div style="display: flex; margin: 40px">
      <div class="leftText">政治面貌</div>
      <div class="text">
        群众：<span>{{ details.params.massesNum }}</span>
      </div>
      <div class="text">
        团员：<span>{{ details.params.leagueMemberNum }}</span>
      </div>
      <div class="text">
        团员（积极分子）：<span>{{ details.params.activistNum }}</span>
      </div>
      <div class="text">
        团员（预备党员）：<span>{{ details.params.prePartyMemberNum }}</span>
      </div>
      <div class="text">
        团员（党员）：<span>{{ details.params.partyMemberNum }}</span>
      </div>
    </div>
    <div style="display: flex; margin: 40px">
      <div class="leftText">班级职务</div>
      <div class="text">
        班长：<span class="info" v-if="details.params.monitorName">{{
          aesDecrypt(details.params.monitorName)
        }}</span>
      </div>
      <div class="text">
        副班长：<span class="info" v-if="details.params.deputyName">{{
          aesDecrypt(details.params.deputyName)
        }}</span>
      </div>
      <div class="text">
        团支书：<span v-if="details.params.secretaryName">{{
          aesDecrypt(details.params.secretaryName)
        }}</span>
      </div>
      <div class="text">
        心理委员：<span v-if="details.params.psychologicalName">{{
          aesDecrypt(details.params.psychologicalName)
        }}</span>
      </div>
    </div>
    <div style="display: flex; margin: 40px" v-if="details.params.teacherName && details.params.teacherName.length">
      <div class="leftText" style="margin-right: 40px">现任教师</div>
      <div
        class="rightText"
        v-for="(item, index) in details.params.teacherName"
        :key="index"
      >
        {{ aesDecrypt(item) }}
      </div>
    </div>
    <!-- 历任教师 -->
    <div v-if="details.params.teacherHistory && details.params.teacherHistory.length">
      <div class="leftTer">历任教师</div>
      <div
        class="rightTeacher"
        v-for="(item, index) in details.params.teacherHistory"
        :key="index"
      >
        <div class="topText">
          <div class="topArr">
            学期：<span class="infoText">{{ item.termName }}</span>
          </div>
          <div class="topArr" v-if="item.homeroomTeacher && item.homeroomTeacher.length">
            班主任：
            <div
              class="infoText"
              v-for="(he, i) in item.homeroomTeacher"
              :key="i"
            >
              {{ aesDecrypt(he) }}
            </div>
          </div>
          <div class="topArr" v-if="item.counselor && item.counselor.length">
            辅导员：
            <div class="infoText" v-for="(co, i) in item.counselor" :key="i">
              {{ aesDecrypt(co) }}
            </div>
          </div>
        </div>
        <div v-if="item.teachingStaff && item.teachingStaff.length">
          <div class="topArr">
            任课教师：
            <div
              class="infoText"
              v-for="(te, i) in item.teachingStaff"
              :key="i"
            >
              {{ aesDecrypt(te) }}
            </div>
          </div>
        </div>
      </div>
      <!-- <div
        class="rightTeacher"
        v-for="(item, index) in details.params.teacherHistory"
        :key="index"
      >
        <div>
          <div style="display: flex">
            <div>
              学期：<span>{{ item.termName }}</span>
            </div>
            <div v-if="item.classTeachers.homeroomTeacher">
              班主任：
              <div
                v-for="(he, i) in item.classTeachers.homeroomTeacher"
                :key="i"
              >
                {{ aesDecrypt(he) }}
              </div>
            </div>
            <div v-if="item.classTeachers.counselor">
              辅导员：
              <div v-for="(co, i) in item.classTeachers.counselor" :key="i">
                {{ aesDecrypt(co) }}
              </div>
            </div>
          </div>
          <div v-if="item.classTeachers.teachingStaff">
            <div class="rightArr">
              任课教师：
              <div v-for="(te, i) in item.classTeachers.teachingStaff" :key="i">
                {{ aesDecrypt(te) }}
              </div>
            </div>
          </div>
        </div>
      </div> -->
    </div>
  </CurrencyDialog>
</template>
<style lang="scss">
.el-dialog {
  --el-dialog-padding-primary: 0;
  --el-dialog-border-radius: 2px;
  &__header {
    display: flex;
    align-items: center;
    height: 40px;
    background: #e8f3f3;
    font-family:
      PingFang SC,
      PingFang SC;
    font-weight: bold;
    font-size: 16px;
    color: #222222;
    line-height: 24px;
    text-align: left;
    font-style: normal;
    text-transform: none;
    padding-left: 12px;
  }
  &__headerbtn {
    width: 48px;
    height: 40px;
    .el-icon {
      width: auto;
      height: auto;
    }
  }
}

.w400 {
  --el-dialog-width: 400px;
}

.w675 {
  --el-dialog-width: 675px;
}

.w1200 {
  --el-dialog-width: 1200px;
}
</style>
<style lang="scss" scoped>
.lastBox {
  display: flex;
  margin: 40px;
  div {
    // flex: 1;
    width: 33%;
    display: flex;
    .box {
      width: 90px;
      font-size: 16px;
      font-weight: 600;
      text-align: right;
      display: flex;
      justify-content: flex-end;
    }

    span {
      margin-left: 8px;
      font-size: 16px;
      font-weight: 400;
    }
  }
  .lefText {
    width: 100%;
  }
}
.leftText {
  width: 90px;
  font-size: 16px;
  font-weight: 600;
  text-align: right;
  display: flex;
  justify-content: flex-end;
}
.text {
  font-size: 16px;
  font-weight: 600;

  text-align: right;
  display: flex;
  justify-content: flex-end;
  margin-left: 40px;
  span {
    font-weight: 400;
  }
  info {
    width: 80px;
  }
}
.rightText {
  margin-right: 8px;
  font-size: 16px;
  font-weight: 400;
}

.leftTer {
  width: 90px;
  font-size: 16px;
  font-weight: 600;
  margin-left: 65px;
}
.rightTeacher {
  margin-top: -20px;
  margin-left: 170px;
  width: 800px;
  min-height: 80px;
  margin-bottom: 20px;
  .topText {
    display: flex;
    margin-bottom: 10px;
  }
  .topArr {
    display: flex;
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    .infoText {
      font-weight: normal;
      margin-right: 8px;
    }
  }
}
</style>
